import ajax from '@/utils/request'
import { concatUrl } from '@/utils'

/**
 * 建档小程序码查询
 */
export function getMiniQrcode(data, fields: string | object = { fields: 'storeName,id,carLicense,status,statusLabel,mobile,realname,pagePath' }) {
  return ajax({
    url: concatUrl('/v1/car-archive/mini-qrcode', fields),
    data,
    method: 'GET',
  })
}

/**
 * 建档小程序码查询门店（登录建立关系）
 */
export function getMiniQrcodeStore(data, fields: string | object = { fields: 'storeName,id,carLicense,status,statusLabel,mobile,realname,pagePath,storeCode' }) {
  return ajax({
    url: concatUrl('/v1/car-archive/mini-qrcode-v2', fields),
    data,
    method: 'GET',
  })
}

/**
 * 更新车辆信息
 * @param data
 */
export function qrcodeConfirm(data): any {
  let param = {
    id: data.id,
    fields: 'status,id,mobile,carLicense,realname',
  }
  return ajax({
    method: 'PUT',
    url: concatUrl(`/v1/car-archive/mini-qrcode-confirm`, param),
    data,
  })
}


/**
 * 建档小程序码待提交状态更新
 * @param data
 */
export function qrCodewaitConfirm(data): any {
  let param = {
    id: data.id
  }
  return ajax({
    method: 'PUT',
    url: concatUrl(`/v1/car-archive/mini-qrcode-wait-confirm`, param),
    hideLoginModal: false
  })
}
